package demo4;

import java.text.SimpleDateFormat;
import java.util.Date;

// 领取物资类
class SupplyReceiving {
    // 领取编号
    private String receivingId;
    // 学生编号
    private String studentId;
    // 用品编号
    private String supplyId;
    // 领取时间
    private Date receivingTime;
    // 领取数量
    private int quantity;

    // 构造函数，用于初始化领取物资信息
    public SupplyReceiving(String receivingId, String studentId, String supplyId, Date receivingTime, int quantity) {
        this.receivingId = receivingId;
        this.studentId = studentId;
        this.supplyId = supplyId;
        this.receivingTime = receivingTime;
        this.quantity = quantity;
    }

    // 领取记录方法
    public void recordReceiving() {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        System.out.println("领取编号: " + receivingId);
        System.out.println("学生编号: " + studentId);
        System.out.println("用品编号: " + supplyId);
        System.out.println("领取时间: " + sdf.format(receivingTime));
        System.out.println("领取数量: " + quantity);
    }

    // 显示某时间段的物资领取信息方法
    public void displayReceivingInfo(Date startTime, Date endTime) {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        if (receivingTime.after(startTime) && receivingTime.before(endTime)) {
            System.out.println("领取编号: " + receivingId);
            System.out.println("学生编号: " + studentId);
            System.out.println("用品编号: " + supplyId);
            System.out.println("领取时间: " + sdf.format(receivingTime));
            System.out.println("领取数量: " + quantity);
        }
    }

    // 修改领取数量方法
    public void modifyQuantity(int quantity) {
        this.quantity = quantity;
        System.out.println("领取编号: " + receivingId + " 领取数量已修改为: " + quantity);
    }
}